﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using MockPrjTeam2.Common;
using MockPrjTeam2.Entity;

namespace MockPrjTeam2.DAO
{
    public class CountryDao
    {
        public List<Country> GetAllCountry()
        {
            const string getCountryQuery = @"SELECT CountryID,CountryName FROM Country";
            var listCountry = new List<Country>();
            using (var helper = new SqlHelper())
            {
                var reader = helper.ExecuteReader(getCountryQuery, null);
                while (reader.Read())
                {
                    var country = new Country(reader.GetInt32(0), reader.GetString(1));
                    listCountry.Add(country);
                }
            }
            return listCountry;
        }
    }
}